;(function(w){
	w.layerIndex = 0;
	w.uploadElement;
	w.uploadImage=function(that,title,useThumb,w,h){
		uploadElement=that;
		w=undefined==w?0:w;
		h=undefined==h?0:h;
		title=undefined==title?'temp':title;
		useThumb=undefined==useThumb?0:useThumb;
		var url = base+'/anon/material/image?t='+useThumb+'&w='+w+'&h='+h+'&n='+title;
		layerIndex = layer.open({
		    type: 2,
		    area: ['450px', '350px'],
		    fix: true,
		    title: '上传图片',
		    content: url
		});
	}
	w.preViewImage=function(that){
		var path = $(that).prev().prev().val();
		if(!path||path==""){
			layer.alert("无图片预览!",{icon:0});
			return;
		}
		layer.open({
		    type: 1,
		    area: ['400px', '400px'],
		    title: false,
		    skin: 'layui-layer-nobg',
		    shadeClose: true,
		    content: '<p style="text-align: center;"><img src="'+base+path+'" alt="无法显示图片" style="width:100%;height:100%;" /></p>'
		});
	}
	w.closeWin=function(url){
		if(null==url){
			layer.msg("上传失败，请重新上传！",{shade: [0.8, '#393D49']});
			layer.close(layerIndex);
			return;
		}
		layer.msg("上传成功",{shade: [0.8, '#393D49']});
		layer.close(layerIndex);
		$(uploadElement).prev().val(url);
	}
})(window);